package util;

import java.io.*;

public class ChangeEncoding {
    public static void main(String[] args) throws IOException {
        File folder = new File("wordstat");
        for (File file : folder.listFiles()) {
            if (file.getName().endsWith("phrases.txt")) {
                System.out.println(file);
                FileInputStream fis = new FileInputStream(file);
                BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
                FileOutputStream fos = new FileOutputStream(file.getPath().replace(".txt", "-ascii.txt"));
                PrintStream out = new PrintStream(fos, false, "ASCII");
                int nextChar;
                String line;
                while((line = reader.readLine()) != null) {
                    System.out.println(line);
                    out.println(line);
                }
//                while ((nextChar = reader.read()) != -1) {
//                    System.out.println(new String(nextChar);
//                }

                out.flush();
            }
        }
    }
}
